package structure;

import utils.TimeUtils;

import java.time.Duration;
import java.time.LocalDateTime;

/**
 * @author zhangjianzhong
 * @create 2021-11-19 21:30
 *
 * 一条监听记录的样子：
 * listen_tx 2021-11-16T14:00:24.151+08:00 from:0ae2452e-a35f-42d8-82b6-81dbfbdc0a19 to:80757dd7-1012-411f-89ac-d06f1676531b tx:24cf43ba-fe46-406e-b54d-13d62c97e557
 *  2021-11-16T14:00:24.151是个LocalDateTime,三位的毫秒已经很不准确了。。。
 *  LocalDateTime.now();//2021-11-19T22:14:00.318599800 第四位开始就是纳秒了
 *
 */
public class TranscationRoute {
    public String transHash;
    public String fromNode;
    public String routeTime;
    public Long relavateTimeStamp;
    public double weight;

    public TranscationRoute(String dateTime,String fromNode,String transHash) {
        this.transHash = transHash;
        this.fromNode=fromNode;
        this.routeTime=dateTime;
        //this.routeTimeFormat = TimeUtils.changeStrignToDate(dateTime);
        this.weight=0.0;
    }

    public static void main(String[] args) {
        LocalDateTime d1=TimeUtils.changeStrignToDate("2021-11-16T14:00:24.151");
        LocalDateTime d2=TimeUtils.changeStrignToDate("2021-11-16T14:00:24.111");
        Duration duration=Duration.between(d1,d2);
        System.out.println(duration.toMillis()); //返回的是个long
    }
}
